package com.jiazhong.shixi.diancan_xitong.controller;


import com.jiazhong.shixi.diancan_xitong.bean.Shopping_cart;
import com.jiazhong.shixi.diancan_xitong.mapper.Shopping_cartMapper;
import com.jiazhong.shixi.diancan_xitong.util.JsonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/shopping_cart")
@RestController
public class  Shopping_cartController {

    @Resource
    private Shopping_cartMapper shopping_cartMapper;
    @RequestMapping("/find")
    public JsonResult findById(Integer cus_id) {
        List<Shopping_cart>list = shopping_cartMapper.findById(cus_id);
        JsonResult result = new JsonResult(true,200,list,"");
        return result;
    }

    @RequestMapping("/add")
    public JsonResult addCart(Shopping_cart cs) {
        shopping_cartMapper.add(cs);
        JsonResult result = new JsonResult(true,200,"success","");
        return result;
    }

    @RequestMapping("/update")
    public JsonResult updateCart(Shopping_cart cs) {
        shopping_cartMapper.update(cs);
        JsonResult result = new JsonResult(true,200,"success","");
        return result;
    }

    @RequestMapping("/remove1")
    public JsonResult remove1(Shopping_cart cs) {
        shopping_cartMapper.remove1(cs);
        JsonResult result = new JsonResult(true,200,"success","");
        return result;
    }

    @RequestMapping("/remove2")
    public JsonResult remove2(Shopping_cart cs) {
        shopping_cartMapper.remove2(cs);
        JsonResult result = new JsonResult(true,200,"success","");
        return result;
    }


}
